TimeSerial (hour, minute, second)

Basic and Crystal syntax.

Arguments
Returns

Time value.

Action

TimeSerial returns a Time value specifying the time for a specific hour, minute and second.

Typical uses

TimeSerial can be used instead of CTime or TimeValue to create a Time value out of an hour, minute and second.

A useful feature of TimeSerial is that the hour, minute and second arguments do not need to fall within normally valid ranges. That is, the hour does not need to be from 0 to 24 and the minute and second do not need to be from 0 to 59. Such times are interpreted as relative times, and TimeSerial will produce a valid Time value. This can be used to easily perform many computations with times.

Examples

The following examples are applicable to both Basic and Crystal syntax:

TimeSerial (18, 45, 0)

TimeSerial (22 - 3, 15 - 30, 0)

Both return the same time 6:45 PM. The second has the interpretation that 3 hours and 30 minutes before 10:15 PM is 6:45 PM.

TimeSerial (10 + 20, 30 + 55, 0)

Returns 7:25 AM. What it means is that 20 hours and 55 minutes from 10:30 AM is 7:25 AM (of the next day).

Comment

This function is similar to the Visual Basic function of the same name. There is a difference when the relative times span more than one day. For example, in Crystal Reports,

TimeSerial (1, 0 - 180, 0)

returns 10:00 PM. This has the interpretation that 180 minutes before 1:00 AM is 10:00 PM. However, the same function call in Visual Basic returns 2:00 AM. The difference occurs because 180 minutes before 1:00 AM moves the time to 10:00 PM of the previous day and Visual Basic then handles this differently.



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com